<?php
include dirname(__FILE__).'/data.php';
class Data_dpost extends Data {
    public function getMyPostTotal($uid) {
        if(!$uid) return false;
        $db = $this->connect('note');
        if(!$db) return false;
        $sql = "select count(*) from my_post where uid={$uid}";
        $return = $db->query($sql);
        $total = $db->fetchRow($return);
        return $total[0]?$total[0]:0;
    }
    public function getMyPost($uid,$start=0,$limit=10) {
        if(!$uid) return false;
        $db = $this->connect('note');
        if(!$db) return false;
        $sql = "select * from my_post where uid={$uid} order by dateline desc limit {$start},{$limit}";
        $return = $db->query($sql,1);
        $list = $db->fetch($return);
        return $list;
    }
    public function addPost($uid, $title,$info) {
        if(!$uid) return false;
        $db = $this->connect('note');
        if(!$db) return false;
        $time = time();
        $sql = "insert into my_post(`uid`,`title`,`info`,dateline) values({$uid},'{$title}','{$info}',{$time})";
        $return = $db->query($sql,1);
        if($db->allRows()>0) {
            return $db->insertId();
        }
        return false;
    }
}

?>